<!doctype html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<link href="download.css" rel="stylesheet">
<script src="jquery-2.1.1.min.js"></script>
<script src="common.js"></script>
<script type="text/javascript">
    var channel = getQueryString("channel");

    $(document).ready(function(){
        $.ajax({url:"download1.json",async:false,
            success: function(res){
                $("#download_click").on("click",function(){
                    if(channel != ""){
                        var data = {"url":"http://app-66xiaoqu.babytree.com/rest/v1.0/mobile/shares/addQrcodeStatistic","method":"post","data":"channel="+channel};
                        netWork(data,result);
                    }
                });

                var u = navigator.userAgent, app = navigator.appVersion;
                var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
                var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
                var ua=navigator.userAgent.toLowerCase();
                var isWx = ua.match(/MicroMessenger/i)=="micromessenger"
                var url="#";
                var os="";
                var yesno_label="";
                var result = function(d){
                    console.log(d);
                    //alert(d);
                    $("#download_ico").attr("href",url);
                    $("#download").attr("href",url);
                    $("#download")[0].click();
                };

                if(isAndroid)
                {
                    url=res.android.default;
                    os="Android";
                    $("div.device_text span").css("font-size","16px");
                    if(isWx)
                    {
                        url=res.android.wx;
                        os="Android";
                    }
                }
                else if (isiOS)
                {
                    url=res.ios.default;
                    if(isWx)
                    {
                        url=res.android.default;
                    }
                    os="iOS";
                }
                else{
                    yesno_label="不";
                }

                if(channel == ""){
                    $("#download_ico").attr("href",url);
                    $("#download2").attr("href",url);
                }
                $("#targetOS").html(os);
                $("#yesno_label").html(yesno_label);
                //location.href=res.android.default;
            },error:function(res){

            }
        });
    });

</script>


<body>
    <div class="icon_wrap" style="text-align:center;">
        <a id="download_ico" href="">
            <img src="icon.png" class="appicon" >
        </a>
        <div>
            <img src="66xq.png" class="xiaoqu">
        </div>
    </div>
    <div class="device_text" style="text-align:center;">
        <span>此版本<span id="yesno_label"></span>适用于<span id="targetOS"></span>设备</span>
    </div>
    <div class="download_btn" style="text-align:center;">
        <div style="margin-left:15%; margin-right:15%" id="download_click">
            <a href="javascript:"  class="btn-u btn-u-lg" id="download2"> <img src="bottonl.png" class="botton" ></a>
        </div>
    </div>
    <a id="download" href=""></a>

</body>

</html>